# -*- coding:utf-8 -*-
import os
import os.path
import re
import logging
import json
#-------------------FileUtil------------------------------------------------
class FileUtil:
	def __init__(self):
		pass

	def read(self,path):
		is_exists= os.path.exists(path)
		if not is_exists:
			f = open(path, 'w',encoding="utf-8")
			f.close()
		files = open(path,"r")
		strs= files.read()
		# strs = strs.encode('UTF-8')
		files.close()
		return strs
		pass

	def read_json(self,path):
		content =self.read(path)
		jobject = {}
		if content:
			jobject=json.loads(content)
		return jobject
		pass

	def write(self,path,content):
		f = open(path, 'w+',encoding="utf-8")
		f.write(content)
		f.close()
		pass

	def write_json(self,path,json_object):
		jstr = json.dumps(json_object)
		self.write(path,jstr)
		pass

